<template>
<div>
  <tou/>
  <second/><br>
  <el-carousel :interval="4000" type="card" height="200px">
    <el-carousel-item v-for="item in 6" :key="item">
    </el-carousel-item>
  </el-carousel>
  <el-row :gutter="10">
    <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"><div style="display: inline-block;width: 200px;margin-left: 150px" class="grid-content bg-purple">推荐<span style="color: orangered">酒店</span></div></el-col>
    <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"><div class="grid-content bg-purple-light"></div></el-col>
    <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11">
      <el-badge class="item" >
        <el-button @click="findcityhotel(city.cityId)" v-for="city in fourcity" :key="city.cityId" size="small" style="width: 100px;height: 50px;font-size: 20px">
          {{city.cityName}}</el-button>
        <el-button @click="drawer = true" type="primary" style="margin-left: 16px;width: 100px;height: 50px;font-size: 20px">
          更多
        </el-button>
        <el-drawer
          :visible.sync="drawer"
          :direction="direction"
          >
          <el-button v-for="city in citys" :key="city.cityId" @click="findcityhotel(city.cityId)">{{city.cityName}}</el-button>

        </el-drawer>

      </el-badge>

    </el-col>
    <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"><div class="grid-content bg-purple-light"></div></el-col>
  </el-row>
<br><br><br><br>
  <div style="width: 1188px;margin: 0 auto" >
    <el-row>
      <el-col :span="4" v-for="(o, index) in hotels" :key="o.hotelId" :offset="(index)%5 == 0 ? 0 : 1" style="margin-top: 10px">
        <el-card :body-style="{ padding: '0px' }" >
          <img :src="o.hotelPic" class="image" style="width: 170px;height: 150px;margin-left: 12px;margin-top: 10px">
          <div style="padding: 14px;">
            <span>{{o.hotelName}}</span>
            <div class="bottom clearfix">

              <span class="time" style="margin-top: -10px">{{ o.hotelInfo }}</span><br><br>
              <el-rate
                v-model="o.hotelScore"
                disabled
                show-score
                text-color="#ff9900"
              >{{o.hotelScore}}
              </el-rate><hr>
              <span class="time" style="color:#aa0000;font-size: 18px;margin-left:-65px;font-weight: 600">¥{{ o.hotelPrice }}</span>

              <el-button type="text" class="button" @click="tofindbed(o.hotelId)">详情</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>



  </div>

  <div>
    <img src="../img/hotel1.png">
  </div>
  <div>
    <img src="../img/hotel2.png">
  </div>
  <div>
    <img src="../img/hotel3.png">
  </div>
  <div>
    <img src="../img/hotel4.png">
  </div>
  <div>
    <img src="../img/hotel5.png">
  </div>

</div>
</template>

<script>
import Second from "./second.vue";
import Tou from "./tou.vue";
import {h} from "vue";

export default {
  name: "hotel",
  components: {Tou, Second},
  data(){
    return{
      drawer: false,
      direction: 'rtl',
      fourcity:[],
      citys:[],
      hotels:[],
      value: 5,
    }
  },
  methods: {
    h,
    findallcity(){
      this.$axios.get('/city/findallcitys').then(data=>{
        this.citys=data.data.data;
        for (var i = 0; i < 4; i++) {
          this.fourcity[i]=data.data.data[i]
        }
      })
    },
    findcityhotel(cityId){
      if (cityId==null){
        cityId=19
      }
      this.$axios.get('/hotel/citytohotel',{
        params:{
          cityId:cityId
        }
      }).then(data=>{
        console.log(data.data.data)
        this.hotels=data.data.data
      })
    },
    tofindbed(id){
      localStorage.setItem("hotelId",id)
      this.$router.push("/bed")
    }

  },
  mounted() {
    var city=localStorage.getItem("city")
    this.findallcity()
    this.findcityhotel(city)
  }
}
</script>

<style scoped>
.sou {
  margin-top: 25px;
}

.el-dropdown {
  vertical-align: top;
}

.el-dropdown + .el-dropdown {
  margin-left: 15px;
}

.el-icon-arrow-down {
  font-size: 12px;
}

.centered-menu-item {
  display: flex;
  justify-content: center;
  background-color: #5199FD;
}

.el-menu--horizontal > .el-menu-item.is-active {
  border: none;
}

.daohang {
  margin-left: 60px;
  line-height: 60px;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 18px;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
.xuanze{
  position: absolute;
  left: 20%;
  top: 250px;
  background-color: #fff;
  z-index: 9;
  width: 500px;
}
.block {
  margin-left: -15px;
}
.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both
}
.bottom[data-v-47323bf2] {
  margin-top: 13px;
  line-height: 12px;
  display: contents
}






.bg-purple {
  font-size: 40px;
  font-weight: 500;
  display: inline-block;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}



.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
.el-icon-arrow-down {
  font-size: 12px;
}


.el-carousel__item h3 {

  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(3) {
  background-image: url("https://img.zcool.cn/community/017ada5e5c6109a801216518216e88.jpg@1280w_1l_2o_100sh.jpg");
  background-size: cover;
}
.el-carousel__item:nth-child(4) {
  background-image: url("https://cbu01.alicdn.com/img/ibank/2016/633/890/2816098336_2119179195.jpg");
  background-size: cover;
}
.el-carousel__item:nth-child(5) {
  background-image: url("https://img.zcool.cn/community/0108d75be2a7c5a80121ab5d8e45e0.jpg@1280w_1l_2o_100sh.jpg");
  background-size: cover;
}
.el-carousel__item:nth-child(6) {
  background-image: url("https://img.zcool.cn/community/018a5f5be2a7c6a801209252fefabb.jpg@1280w_1l_2o_100sh.jpg");
  background-size: cover;
}
.el-carousel__item:nth-child(7) {
  background-image: url("https://img.zcool.cn/community/01a608591bf0c4a801216a3eceb086.jpg@1280w_1l_2o_100sh.jpg");
  background-size: cover;
}
.el-carousel__item:nth-child(8) {
  background-image: url("https://img.zcool.cn/community/01496c590ab077a80121455072259d.jpg@2o.jpg");
  background-size: cover;
}

</style>
